package Test;
//22:14   1 2
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String str = input.nextLine();
        Boolean ans = function(str);
        if (ans) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }


    public static boolean function(String str) {
        int n = str.length();
        Stack<Character> lefts = new Stack<>();
        if (str == null || str.length() != n) {
            return false;
        }
        for (int i = 0; i < n; i++) {
            if (str.charAt(i) == '(' || str.charAt(i) == '[' || str.charAt(i) == '{') {
                lefts.push(str.charAt(i));
            } else if (str.charAt(i) == ')' || str.charAt(i) == ']' || str.charAt(i) == '}') {
                if (lefts.empty()) {
                    return false;
                } else {
                    lefts.pop();
                }
            } else {
                return false;
            }
        }
        if (!lefts.empty()) {
            return false;
        } else {
            return true;
        }
    }
}


